var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        };
Object.defineProperty(n, "__esModule", {value: !0});
var a,
    s = e("events"),
    c = e("sound"),
    l = e("vibrate"),
    u = e("guide-manager"),
    p = e("player-theme"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
        ((a = cc.Component),
        i(h, a),
        (h.prototype.start = function () {
            (this.btn.interactable = !1), (this.btn.clickSoundEffect = !1), s.operEvent.on(this.onOperTap.bind(this));
        }),
        (h.prototype.onOperTap = function (e) {
            null != e &&
                null != e.action &&
                (s.default.mergeBtnCount == e.action && null != e.data
                    ? (this.setBtnInteractable(e.data.count && 0 < e.data.count),
                      0 < e.data.count &&
                          (u.GuideManager.ins.checkGuide(u.GuideStep.merge, this.btn.node) ||
                              u.GuideManager.ins.checkGuide(u.GuideStep.merge1, this.btn.node)))
                    : s.default.mergeBtn == e.action && null != e.data && this.setBtnInteractable(e.data.isCan));
        }),
        (h.prototype.setBtnInteractable = function (e) {
            var t = this;
            (this.btn.interactable = !0),
                (this.btn.node.opacity = e ? 255 : 150),
                e &&
                    u.GuideManager.ins.isNeedWeakGuide() &&
                    u.GuideManager.ins.getIsNeedMergeWeakGuide() &&
                    !this.isMergeGuideing &&
                    ((this.isMergeGuideing = !0),
                    this.scheduleOnce(function () {
                        u.GuideManager.ins.showWeakMerge(t.btn.node);
                    }, 10));
        }),
        (h.prototype.merge = function () {
            console.log("merge btn"),
                (this.isMergeGuideing = !1),
                this.unscheduleAllCallbacks(),
                u.GuideManager.ins.hideHand(),
                (this.btn.interactable = !1),
                (this.btn.node.opacity = 150),
                "coin" === p.playerTheme.getCurThemeName()
                    ? c.sound.play(c.Sound.MERGE)
                    : c.sound.play(c.Sound.MJ_MERGE),
                l.vibrate.play(l.VibrateNewType.LONG),
                s.operEvent.emit({action: s.default.merge, data: null});
        }),
        r([t(cc.Button)], h.prototype, "btn", void 0),
        r([e], h));
function h() {
    var e = (null !== a && a.apply(this, arguments)) || this;
    return (e.btn = null), (e.isMergeGuideing = !1), e;
}
n.default = e;
